/***********************************************************************
 * Module:  DataDictionaryController.java
 * Author:  Administrator
 * Purpose: Defines the Class DataDictionaryController
 ***********************************************************************/

package ishitong.dataDictionary.controller;

import ishitong.common.model.SysCode;
import ishitong.common.service.biz.SysCodeService;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/** @pdOid 44269b8c-5571-4e4c-945d-c54d3aa91814 */
@Controller
public class DataDictionaryController {
   /** @pdOid 72c72822-0d3d-411a-a4ca-6630d798317a */
   private static final String DAT_DIC_SCH = "/dataDictionary/dataDictionarySearch";
   /** @pdOid 085f0e3a-07a8-4549-adef-7fcca88de980 */
   private static final String DAT_DIC_SCH_LST = "/dataDictionary/dataDictionarySearchList";
   /** @pdOid a4cfa7d6-3105-4087-9743-e2bb63b44f8d */
   private static final String DAT_DIC_EDT = "/dataDictionary/dataDictionaryEdit";
   /** @pdOid 15ab71fd-3e14-47be-b0ff-4dbb0f367a30 */
   private static final String DAT_DIC_VIW = "/dataDictionary/dataDictionaryView";
   /** @pdOid d9dfa953-79f3-463e-af34-9a288f1f8091 */
   private static final String DAT_DIC_TRM = "/dataDictionary/dataDictionaryTreeMenu";
   /** @pdOid f0984a94-c38a-49b4-babb-1a03219ca26a */
   @Autowired
   private SysCodeService sysCodeService;
   
   /** @param request
    * @pdOid 717ad500-ee32-4b7f-80e2-01a2bc85d2e3 */
   @RequestMapping(value = "/showDataDictionarySearch.do")
   public ModelAndView handleShowDataDictionarySearch(HttpServletRequest request) {
   	return new ModelAndView(DAT_DIC_SCH);
   }
   
   /** @param request
    * @pdOid efb1fb31-a231-4442-b407-63c394312836 */
   @RequestMapping(value = "/ajaxDataDictionaryTreeMenu.do")
   public ModelAndView handleAjaxDataDictionaryTreeMenu(HttpServletRequest request) {
   	Map<String, Object> model = new HashMap<String, Object>();
   	SysCode sysCode = new SysCode();
   	model.put("treeViewData", sysCodeService.getSysCodeByCondition(sysCode));
   	return new ModelAndView(DAT_DIC_TRM, model);
   }
   
   /** @param request 
    * @param sysCode
    * @exception Exception
    * @pdOid b5144318-78a8-4115-bc68-54a6f1cac5c4 */
   @RequestMapping(value = "/ajaxDataDictionarySearchList.do")
   public ModelAndView handleAjaxFindDataDictionarySearchList(HttpServletRequest request, SysCode sysCode) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		List<SysCode> listSysCode = sysCodeService.getSysCodeByCondition(sysCode);
   		//model.put("sysCode", sysCode);
   		model.put("listSysCode", listSysCode);
   		return new ModelAndView(DAT_DIC_SCH_LST, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param sysCodeId
    * @exception Exception
    * @pdOid 5cc6b56f-e405-4aab-940a-e9e7a8a85c8b */
   @RequestMapping(value = "/ajaxShowDataDictionaryEdit.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxShowDataDictionaryEdit(HttpServletRequest request, SysCode sysCodeId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		if(sysCodeId != null){
   
   		}
   		return new ModelAndView(DAT_DIC_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param sysCode
    * @exception Exception
    * @pdOid aa125d20-704b-44c0-a779-5d75e9d638e2 */
   @RequestMapping(value = "/ajaxSaveDataDictionary.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxSaveDataDictionary(HttpServletRequest request, SysCode sysCode) throws Exception {
   	try {
   		if(sysCode.getId()!=null){
   			sysCodeService.updateSysCodeByID(sysCode);
   		}else{
   			sysCodeService.addSysCode(sysCode);
   		}
   		return new ModelAndView(DAT_DIC_SCH);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param sysCodeId 
    * @param dataDictionaryId
    * @exception Exception
    * @pdOid 38a8f240-9fd1-4a0d-b847-69eba290fc14 */
   @RequestMapping(value = "/ajaxShowDataDictionaryView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowDataDictionaryView(HttpServletRequest request, SysCode sysCodeId, String dataDictionaryId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		return new ModelAndView(DAT_DIC_VIW, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param response 
    * @param dataDictionaryIds
    * @exception Exception
    * @pdOid 67b261f8-5ae5-4e04-9fa4-c0417120e687 */
   @RequestMapping(value = "/ajaxDeleteDataDictionaryByIds.do",method = RequestMethod.POST)
   public void handleAjaxDeleteDataDictionaryByIds(HttpServletRequest request, HttpServletResponse response, Long dataDictionaryIds) throws Exception {
   	try {
   		sysCodeService.deleteSysCodeByID(dataDictionaryIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	} 	
   }

}